﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<dynamic>" %>
<script type="text/javascript" src="../../Scripts/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="../../Scripts/jquery-ui-1.8.21.custom.min.js"></script>
<table id="listUser">
<tr>
    <th>Username</th>
    <th>Email</th>
    <th>Stato</th>
    <th>Tipo</th>
</tr>
<% foreach (MvcSite.Models.User utente in (List<MvcSite.Models.User>)ViewData["Utenti"])
   {
%>
    <tr>
        <td><%=  utente.Username %></td>
        <td><%=  utente.Email %></td>
        <td>
        <%= Html.DropDownList("UserType", utente.Tipo.ToSelectList(), new { rel = utente.Username })%>
        </td>
        <td><%=  Html.DropDownList("StatoReg", utente.Stato.ToSelectList(), new { rel = utente.Username })%></td>
    </tr>
<% } 
%>
</table>
<button id="save">Salva</button>

<script type="text/javascript">
    $(function () {
        function Tipo_Stato() {
            this.UserType = "";
            this.StatoReg = "";
        }
        var tipo = new Array();
        var stato = new Array();
        $("#save").button().attr('disabled', true).click(function () {
            $.ajax();
        });
        //select list change
        $('select').change(function () {
            if ($(this).attr('id') == 'UserType') {
                tipo[$(this).attr('rel')] = $(this).val();
            }
            else if ($(this).attr('id') == 'StatoReg') {
                stato[$(this).attr('rel')] = $(this).val();
            }
            $("#save").button().attr('disabled', false);
        });
    });
</script>